package cn.tedu.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.thymeleaf.context.Context;

import cn.tedu.dao.DeptDao;
import cn.tedu.dao.EmpDao;
import cn.tedu.entity.Dept;
import cn.tedu.entity.Emp;
import cn.tedu.utils.ThyUtils;

/**
 * Servlet implementation class ShowUpdateServlet
 */
public class ShowUpdateServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String empno=request.getParameter("id");
		EmpDao dao=new EmpDao();
		Emp e=dao.findEmpBympno(empno);
		//查询所有部门
		DeptDao deptdao=new DeptDao();
		List<Dept> depts=deptdao.findAll();
		//把查询到的员工信息和所有部门信息传递到修改页面
		Context context=new Context();
		context.setVariable("e", e);
		context.setVariable("depts", depts);
		
		ThyUtils.write("update", response, context);
	}

}
